package com.example.fw;

import java.io.IOException;
import java.util.Properties;

public class ApplicationManager {
	
	private static ApplicationManager singleton;
	private Properties properties;
	private ContactHelper contactHelper;
	private ProcessHelper processHelper;
	private AutoItHelper autoitHelper;

	public static ApplicationManager getInstance (Properties pro) throws IOException{
		if (singleton == null){
			singleton = new ApplicationManager();
			singleton.setProperties(pro);
			singleton.start();
		}
		return singleton;
	}
	
	public void setProperties (Properties properties){
		this.properties = properties;
	}
	
	public String getProperties (String key) {
		return properties.getProperty(key);
	}

	public void start() throws IOException {
		getProcessHelper().startAppUnderTest();
	}

	public void stop() {
		getProcessHelper().stopAppUnderTest();
	}

	public ProcessHelper getProcessHelper() {
		if (processHelper == null){
			processHelper = new ProcessHelper(this);
		}
		return processHelper;
	}

	public ContactHelper getContactHelper() {
		if (contactHelper == null){
			contactHelper = new ContactHelper(this);
		}
		return contactHelper;
	}

	public AutoItHelper getAutoItHelper() {
		if (autoitHelper == null){
			autoitHelper = new AutoItHelper(this);
		}
		return autoitHelper;
	}
}
